package com.yonyou.pmclouds.workstartreport.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.workstartreport.entity.WorkStartCheckVO;
import com.yonyou.pmclouds.workstartreport.entity.WorkStartVO;
import com.yonyou.pmclouds.workstartreport.mapper.WorkStartCheckMapper;
import com.yonyou.pmclouds.workstartreport.mapper.WorkStartMapper;

public class WorkStartDeleteProcessor implements SingleProcessor<WorkStartVO> {
    private WorkStartMapper mapper;
    private WorkStartCheckMapper checkMapper;
    public WorkStartDeleteProcessor(WorkStartMapper mapper,WorkStartCheckMapper checkMapper){
        this.checkMapper=checkMapper;
        this.mapper=mapper;
    }

    @Override
    public void process(WorkStartVO vo, WorkStartVO orig) throws BusinessException {
        String pkWorkstartreport = vo.getPkWorkstartreport();
        WorkStartVO workStartVO = mapper.selectReport(pkWorkstartreport);
        String pkWorkquality = workStartVO.getPkWorkquality();
        WorkStartCheckVO[] workStartCheckVOS = checkMapper.selectAllCheck(pkWorkquality,pkWorkstartreport);
        for(WorkStartCheckVO w:workStartCheckVOS){
            checkMapper.delete(w.getPkCheck());
        }

    }
}
